#include <bits/stdc++.h>
// 2025/02/04
// tag: 
// Author: Zhang Muen
using namespace std;

using int64 = int64_t;

class MQueue {
private:
    deque<int> q, pos;

public:
    void push(int x, int i)
    {
        while (!q.empty() && q.back() > x)
            q.pop_back(), pos.pop_back();
        q.push_back(x), pos.push_back(i);
    }
    void pop(int i)
    {
        if (!pos.empty() && pos.front() < i)
            q.pop_front(), pos.pop_front();
    }
    int get_min()
    {
        return q.front();
    }
    int get_max()
    {
        return q.back();
    }
};

int n, news[2000001];

signed main()
{
    cin >> n;
    MQueue q;
    for (int i = 1; i <= n; i++)
        cin >> news[i];
    for (int i = 1; i < n; i++)
        news[i + n] = news[i];
    for (int i = 1; i < 2 * n; i++)
        news[i] += news[i - 1];
    int cnt = 0;
    for (int i = 1; i < 2 * n; i++){
        q.pop(max(i - n + 1, 1));
        q.push(news[i], i);
        if (i >= n && q.get_min() >= news[i - n])
            cnt++;
    }
    cout << cnt;
    return 0;
}